import {Component, EventEmitter,ViewChild, Input, OnInit, Output} from '@angular/core';
import { InitService } from '../../public/serve/init/init.service';
import { appProjectUrl } from './project.url';
import { project } from './project.data';
import { RemoveTableService } from '../../public/serve/remove-table/remove-table.service';
import { Service } from '../../server/server';
import { CudTableService } from '../../public/serve/cud-table/cud-table.service';
import { ProjectTableComponent } from './project-table/project-table.component';
declare var $:any;

@Component({
  selector: 'app-project',
  templateUrl: './project.component.html',
  styleUrls: ['./project.component.css']
})
export class ProjectComponent implements OnInit {

  @ViewChild("table") table : ProjectTableComponent;

  @Input() status: any  = '';
  @Input() searchData: any;
  right: any = {
    "systemProject": {},
  };

  constructor( 
    public initService: InitService,
    public removeTableService: RemoveTableService,
    public request: CudTableService,
    public server: Service
  ){
    this.right = $.extend(this.right, server.getRight());
  }

  isActive = this.server.isActive;
  ngOnInit() {
    this.server.eventEmit.subscribe((value: any)=>{
      this.isActive = value;
    });
  }

 /**
   * 分页
   * @param pagination 
   */ 
  _pagination(pagination: Array<any>) {
    project.pagination.pageNumber = pagination[0].pageNumber;
    project.pagination.pageSize   = pagination[0].pageSize;
    project.pagination.naturalNum = (project.pagination.pageNumber - 1) * project.pagination.pageSize;
    this.table.getProjectList();
  }

  //搜索
  search() {
    project.retrieval.queryCriteria = this.searchData;
    project.retrieval.status = this.status;
    this.table.getProjectList();
  }
  //响应搜索
  changesearch() {
      this.search();
  }

}
